const initialState = { userInfo: {} as userInfoType, user: {} as userType };

export default function userReducer(state = initialState, action: any): typeof initialState {
  switch (action.type) {
    case 'user/saveUserInfo':
      return {
        ...state,
        userInfo: action.payload,
      };
    case 'user/saveUser':
      return {
        ...state,
        user: action.payload,
      };
    case 'user/updatePhoto':
      return {
        ...state,
        user: { ...state.user, photo: action.payload },
      };
    default:
      return state;
  }
}
type userInfoType = {
  id: string;
  name: string;
  photo: string;
  art_count: number;
  follow_count: number;
  fans_count: number;
  like_count: number;
};

export interface userType {
  id: string;
  photo: string;
  name: string;
  mobile: string;
  gender: number;
  birthday: string;
  intro: string;
}
